package utils

import (
	"crypto/md5"
	"encoding/hex"
	"strconv"
	"time"
)

func GemSnowFlask(UserName string) string {
	hash := md5.New() // 创建md5对象
	nowTime := strconv.Itoa(int(time.Now().Unix()))
	hash.Write([]byte(UserName + nowTime)) // 将字符串转为字节数组并写入md5对象
	sum := hash.Sum(nil)                   // 计算MD5值
	toString := hex.EncodeToString(sum)
	user_uuid := toString[:8] + "-" + toString[8:16] + "-" + toString[16:24] + "-" + toString[24:]
	//fmt.Println("user_uuid: ", user_uuid)
	return user_uuid
}
